//
//  MeHomeViewController.m
//  GoShop
//
//  Created by mac22 on 14/11/17.
//  Copyright (c) 2014年 郑朝军. All rights reserved.
//

#import "MeHomeViewController.h"
#import "Grouble.h"
#import "FirstTableViewCell.h"
#import "MeHomeTwoTableViewCell.h"
#import "MineModel.h"
#import "GetPlistArray.h"

@interface MeHomeViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong)UITableView * tableView;
@property (nonatomic,strong)NSArray *mineArray;
@end

@implementation MeHomeViewController
// 加载一个plist文件称模型数组
- (NSArray *)mineArray
{
    if (_mineArray == nil) {
        NSArray * mineArray = [GetPlistArray arrayWithString:@"MineInformationData.plist"];
        NSMutableArray * dictArray = [NSMutableArray array];
        
        for (NSDictionary * dict in mineArray) {
            MineModel * mineModel = [MineModel mineModel:dict];
            [dictArray addObject:mineModel];
        }
        _mineArray = dictArray;
    }
    return _mineArray;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self setTableView];
    [self setNav];
    // Do any additional setup after loading the view.
}
// 设置nav
- (void)setNav
{
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithIcon:@"我的" highIcon:@"我的" target:self action:@selector(meClick)];
    
}
- (void)meClick
{
    ZCJLog(@"meClick");
}
- (void)setTableView
{
    self.tableView = [UITableView initWithTableView:CGRectMake(0, 0, ScreenWidth, ScreenHeight-64) withDelegate:self];
//    self.tableView.delegate = self;
//    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, ScreenWidth, ScreenHeight-64)];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];

    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.mineArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    // 第一组
    if (indexPath.row == 0) {
        FirstTableViewCell * cell = [FirstTableViewCell FirstTableViewCell:tableView];
        return cell;
    }else{
        MineModel * model = self.mineArray[indexPath.row];
        MeHomeTwoTableViewCell * cell = [MeHomeTwoTableViewCell MeHomeTwoTableViewCell:tableView mineModel:model];
        return cell;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        return 120;
    }
    return 44;
}
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
    ZCJLog(@"%d",indexPath.row);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
